package com.retailshop.shopuser.schedule;

import com.retailshop.shopuser.service.SignInService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;


/**
 * 更新签到状态
 */
@Component
public class SignInTask {

    @Autowired
    SignInService signInService;

    Logger logger=LoggerFactory.getLogger(SignInTask.class);


    @Scheduled(cron = "0 0 3 * * ?")//每天凌晨3点钟更新
    public void updateSignState(){
        int row=signInService.updateSignState();
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        LocalDateTime localDateTime = LocalDateTime.now();
        if (row > 0) {
            logger.info(dateTimeFormatter.format(localDateTime) + "更新每天签到状态：------------->成功！");
        } else {
            logger.info(dateTimeFormatter.format(localDateTime) + "更新每天签到状态：------------->失败！");
        }

    }





}
